<template>
  <div>
    <div v-if="user.name">
      <h1>欢迎{{ user.name }}玩家！赶快开始游戏吧！</h1>
      <button @click="play">开始游戏</button>----<i>7鬼523</i>
      <div v-if="msg != ''">{{ msg }}</div>
    </div>
    <div v-else>
      请先登陆
      <a @click="$router.push('/')" href="javascript:;">返回登陆界面</a>
    </div>
    <br />
    <br />
    <br />
    <br />
    <a @click="$router.push('/')" href="javascript:;">返回登陆界面</a>
    <audio ref="Audio"></audio>
  </div>
</template>
<script>
import bus from "@/bus.js";
export default {
  data() {
    return {
      user: {},
      msg: "",
    };
  },
  mounted() {
    // this.user = JSON.parse(window.localStorage.getItem("user"));
    this.user = this.$route.query.user;
    bus.$on("user", function (res) {
      console.log(res);
    });
    document.title = "游戏界面";
    this.Audio = this.$refs.Audio;
  },
  methods: {
    play() {
      let _this = this;
      setTimeout(function () {
        _this.$router.push({ path: "/game", query: { user: _this.user } });
      }, 2000);
      this.msg = "正在匹配，请等待其他玩家....";
    },
  },
};
</script>
<style lang="">
</style>